package cc.vv.btpartyjob.jobactivities.delegate

import android.support.v4.view.ViewPager
import android.util.Log
import android.view.View
import android.widget.HorizontalScrollView
import android.widget.RelativeLayout
import android.widget.TextView
import cc.vv.baselibrary.util.ColorUtil
import cc.vv.baselibrary.util.LKCommonUtil
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.baselibrary.view.MyPagerSlidingTabStrip
import cc.vv.btpartyjob.jnimodule.adapter.JniViewPageAdapter
import cc.vv.btpartyjob.jobactivities.R
import cc.vv.mvp.delegate.BaseAppDelegate


/**
 * 示范典型托管类
 * Created by Chen.qi on 2018/10/24.
 */
class DemonstrationTypicalActivityDelegate : BaseAppDelegate() {


    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_demonstration_typical
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_adt_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_adt_topBar)
        titleBar?.setEventInterface(event)
    }


    /**
     * 设置adatper
     */
    fun setAdapterData(adapter: JniViewPageAdapter) {
        getView<ViewPager>(R.id.vp_adt_allPager)?.adapter = adapter
    }

    /**
     * 设置viewPager的监听
     */
    fun bindViewPagerListener(listener: ViewPager.OnPageChangeListener) {
        getView<ViewPager>(R.id.vp_adt_allPager)?.addOnPageChangeListener(listener)
    }

    /**
     * 设置viewPager的位置
     */
    fun setViewpagerPos(pos: Int) {
        getView<ViewPager>(R.id.vp_adt_allPager)?.currentItem = pos
    }


    /**
     * 初始化顶部tal
     */
    fun initTabLayout() {
        val tabView = getView<MyPagerSlidingTabStrip>(R.id.hs_nha_viewTabs)
        tabView?.dividerColor = ColorUtil.setBCColor(R.color.color_FFFFFF)
        tabView?.underlineColor = ColorUtil.setBCColor(R.color.color_FFFFFF)
        tabView?.indicatorColor = ColorUtil.setBCColor(R.color.color_F23515)
        val px = LKCommonUtil.dip2px(3f)
        //页签内文字大小
        val pxs = LKCommonUtil.sp2px(14f)
        tabView?.indicatorHeight = px
        tabView?.scrollOffset = LKCommonUtil.px2sp(40f)
        tabView?.textColor = ColorUtil.setBCColor(R.color.color_5A687C)
        tabView?.textSize = pxs
        tabView?.selectedTextColor = ColorUtil.setBCColor(R.color.color_F23515)
        tabView?.tabBackground = R.drawable.background_tab
        //将TabLayout和ViewPager关联起来。
        tabView?.setViewPager(getView(R.id.vp_adt_allPager))
    }

}